import 'package:flutter/material.dart';
import 'package:cached_network_image/cached_network_image.dart';

class Widget_Cached_Network_Image_Page extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return Widget_Cached_Network_Image_State();
  }

}

class Widget_Cached_Network_Image_State
    extends State<Widget_Cached_Network_Image_Page> {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text("cached_network_image"),
        ),
        body: Container(
          child: Center(
              child: CachedNetworkImage(
                imageUrl: "https://github.com/flutter/plugins/raw/master/packages/video_player/doc/demo_ipod.gif?raw=true",
                placeholder: (context, url) => Image.asset("images/app.png"),
                errorWidget: (context, url, error) =>
                    Image.asset("images/app.png"),
              )
          ),
        ),
      ),
    );
  }
}
/**
 * 从网络获取图片，并保存到缓存
 *  有占位图和加载出错图
 *
 *   CachedNetworkImage({
    Key key,
    @required this.imageUrl,
    this.imageBuilder,
    this.placeholder,//占位图
    this.errorWidget,//加载出错后显示图片
    this.fadeOutDuration: const Duration(milliseconds: 300),//控制placeholder的淡出动画时间
    this.fadeOutCurve: Curves.easeOut,//控制placeholder的淡出动画方式
    this.fadeInDuration: const Duration(milliseconds: 700),//控制目标图像的淡入动画时间
    this.fadeInCurve: Curves.easeIn,//控制目标图像的淡入动画方式
    this.width,
    this.height,
    this.fit,
    this.alignment: Alignment.center,
    this.repeat: ImageRepeat.noRepeat,
    this.matchTextDirection: false,
    this.httpHeaders,
    this.cacheManager,
    this.useOldImageOnUrlChange: false,
    this.color,
    this.colorBlendMode,
    })
 */